package thinking

object 动态混入 {
  def main(args: Array[String]): Unit = {
    val mongo = new Mongo with Operate
    mongo.insert()
    val mysql = new Mysql with Operate {
      override def query(): Unit = {
        println("mysql查询成功")
      }
    }
    mysql.query()
    mysql.insert()
  }

  trait Operate {
    def insert(): Unit = {
      println("插入数据库完成✅")
    }
  }

  class Mongo {}

  abstract class Mysql {
    def query()
  }

}
